package com.kxf.androidtestdemo.activity;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;

import com.kxf.androidtestdemo.R;
import com.kxf.androidtestdemo.service.MyIntentService;

public class IntentServiceActivity extends AppCompatActivity {

    private Intent intent;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_intent_service);

//        new Thread(new Runnable() {
//            @Override
//            public void run() {
//                int i = 0;
//                while (i<10000){
//                    Log.d("IntentServiceActivity", "线程1正在执行。。。");
//                    i++;
//                    try {
//                        Thread.sleep(100);
//                    } catch (InterruptedException e) {
//                        e.printStackTrace();
//                    }
//                }
//            }
//        }).start();
//
//        new Thread(new Runnable() {
//            @Override
//            public void run() {
//                while (true){
//                    Log.d("IntentServiceActivity", "线程2正在执行。。。");
//                    try {
//                        Thread.sleep(100);
//                    } catch (InterruptedException e) {
//                        e.printStackTrace();
//                    }
//                }
//            }
//        }).start();
    }

    public void openServices(View view) {
        Log.d("IntentServiceActivity", "openServices。。。");
        intent = new Intent(this, MyIntentService.class);
        startService(intent);
    }

    public void stopServices(View view) {
        Log.d("IntentServiceActivity", "stopServices。。。");
        stopService(intent);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        Log.d("IntentServiceActivity", "onDestroy。。。");
    }
}
